import { S } from '../../s';
import { IPSAppDELogic } from '../../app/dataentity/ipsapp-delogic';
import { IPSAppDEMethod } from '../../app/dataentity/ipsapp-demethod';
import { IPSAppDataEntity } from '../../app/dataentity/ipsapp-data-entity';
import { IPSNavigateContext } from '../ipsnavigate-context';
import { IPSNavigateParam } from '../ipsnavigate-param';
import { IPSPanelTabPage } from './ipspanel-tab-page';
import { IPSSysPanelTabPanel } from './ipssys-panel-tab-panel';
import { PSSysPanelItemImpl } from './pssys-panel-item-impl';

export class PSSysPanelTabPanelImpl
  extends PSSysPanelItemImpl
  implements IPSSysPanelTabPanel
{
  get dataName(): string {
    return this.M.dataName;
  }

  get dataRegionType():
    | 'NONE'
    | 'LOGINFORM'
    | 'SINGLEDATA'
    | 'MULTIDATA'
    | 'MULTIDATA_RAW'
    | 'INHERIT'
    | 'USER' {
    return this.M.dataRegionType || 'INHERIT';
  }

  get dataSourceType():
    | 'DEACTION'
    | 'DEDATASET'
    | 'DELOGIC'
    | 'ACTIVEDATAPARAM'
    | 'APPGLOBALPARAM'
    | 'TOPVIEWSESSIONPARAM'
    | 'VIEWSESSIONPARAM'
    | 'CUSTOM' {
    return this.M.dataSourceType;
  }

  protected psappdelogic: IPSAppDELogic;
  getPSAppDELogic(): IPSAppDELogic | null {
    if (this.psappdelogic != null) return this.psappdelogic;
    const value = this.M.getPSAppDELogic;
    if (value == null) {
      return;
    }
    const ipsappdataentity = this.getPSAppDataEntity();
    if (ipsappdataentity != null) {
      this.psappdelogic = ipsappdataentity.findPSAppDELogic(value);
    }
    return this.psappdelogic;
  }

  protected psappdemethod: IPSAppDEMethod;
  getPSAppDEMethod(): IPSAppDEMethod | null {
    if (this.psappdemethod != null) return this.psappdemethod;
    const value = this.M.getPSAppDEMethod;
    if (value == null) {
      return;
    }
    const ipsappdataentity = this.getPSAppDataEntity();
    if (ipsappdataentity != null) {
      this.psappdemethod = ipsappdataentity.findPSAppDEMethod(value);
    }
    return this.psappdemethod;
  }

  protected psappdataentity: IPSAppDataEntity;
  getPSAppDataEntity(): IPSAppDataEntity | null {
    return (
      this.psappdataentity ||
      (this.psappdataentity = this.fillObjectModel(
        S._f,
        this.M.getPSAppDataEntity,
        S._2aa,
      ) as IPSAppDataEntity)
    );
  }

  protected psnavigatecontexts: IPSNavigateContext[];
  getPSNavigateContexts(): IPSNavigateContext[] | null {
    return (
      this.psnavigatecontexts ||
      (this.psnavigatecontexts = this.fillChildListModel(
        this.M.getPSNavigateContexts,
        S._8c,
      ) as IPSNavigateContext[])
    );
  }

  findPSNavigateContext(objKey: any): IPSNavigateContext | null {
    return this.getPSModel5(
      S._8c,
      this.getPSNavigateContexts(),
      objKey,
    ) as IPSNavigateContext;
  }

  protected psnavigateparams: IPSNavigateParam[];
  getPSNavigateParams(): IPSNavigateParam[] | null {
    return (
      this.psnavigateparams ||
      (this.psnavigateparams = this.fillChildListModel(
        this.M.getPSNavigateParams,
        S._8a,
      ) as IPSNavigateParam[])
    );
  }

  findPSNavigateParam(objKey: any): IPSNavigateParam | null {
    return this.getPSModel5(
      S._8a,
      this.getPSNavigateParams(),
      objKey,
    ) as IPSNavigateParam;
  }

  protected pspaneltabpages: IPSPanelTabPage[];
  getPSPanelTabPages(): IPSPanelTabPage[] | null {
    return (
      this.pspaneltabpages ||
      (this.pspaneltabpages = this.fillChildListModel(
        this.M.getPSPanelTabPages,
        S._190,
      ) as IPSPanelTabPage[])
    );
  }

  findPSPanelTabPage(objKey: any): IPSPanelTabPage | null {
    return this.getPSModel5(
      S._190,
      this.getPSPanelTabPages(),
      objKey,
    ) as IPSPanelTabPage;
  }

  get reloadTimer(): number {
    return this.M.reloadTimer != null ? this.M.reloadTimer : -1;
  }

  get scriptCode(): string {
    return this.M.scriptCode;
  }

  get showCaption(): boolean {
    return this.M.showCaption != null ? this.M.showCaption : false;
  }
  get cls(): string {
    return 'PSSysPanelTabPanelImpl';
  }
  instanceof(cls: string): boolean {
    if (cls == S._7 || cls == S._3ad || cls == S._192 || cls == S._193)
      return true;
    return super.instanceof(cls);
  }
}
